<div class="rbac-layout-west">
	<div class="operator-show">
	    <div class="zTreeDemoBackground left" style="width: 200px;">
			<ul id="left-menu" class="ztree" style="padding: 0;"></ul>
		</div>
	</div>
</div>
<div class="rbac-layout-center">
    <div id="rbac-main-data" style="position: relative;"></div>
</div>

<script type="text/javascript">
		var curMenu = null, zTree_Menu = null;
		$("#rbac-main-data").panel({height:'100%',method:'get',border:false});
		var setting = {
			view: {
				showLine: false,
				showIcon: false,
				selectedMulti: false,
				dblClickExpand: false,
				addDiyDom: addDiyDom
			},
			data: {
				simpleData: {
					enable: true
				}
			},
			callback: {
				beforeClick: beforeClick,
				onClick:function(event, treeId, treeNode){
					$("#rbac-main-data").panel({
						href:treeNode.aj_url
					});
				}
			}
		};

		var zNodes =[
			{ id:1, pId:0, name:"人员管理", open:true},
			{ id:11, pId:1,aj_url:'model/rbac/user/content.html', name:"人员列表"},
			{ id:13, pId:1,aj_url:'model/rbac/user/content.html', name:"当前在线"},
			{ id:14, pId:0, name:"权限管理", open:true},
			{ id:15, pId:14,aj_url:'model/rbac/user/content.html', name:"资源管理"},
			{ id:16, pId:14,aj_url:'model/rbac/user/content.html', name:"角色管理"},
			{ id:17, pId:14,aj_url:'model/rbac/user/content.html', name:"部门管理"},
		];

		function addDiyDom(treeId, treeNode) {
			var spaceWidth = 5;
			var switchObj = $("#" + treeNode.tId + "_switch"),
			icoObj = $("#" + treeNode.tId + "_ico");
			switchObj.remove();
			icoObj.before(switchObj);

			if (treeNode.level > 1) {
				var spaceStr = "<span style='display: inline-block;width:" + (spaceWidth * treeNode.level)+ "px'></span>";
				switchObj.before(spaceStr);
			}
		}

		function beforeClick(treeId, treeNode) {
			if (treeNode.level == 0 ) {
				var zTree = $.fn.zTree.getZTreeObj("left-menu");
				zTree.expandNode(treeNode);
				return false;
			}
			return true;
		}

		$(document).ready(function(){
			var treeObj = $("#left-menu");
			$.fn.zTree.init(treeObj, setting, zNodes);
			zTree_Menu = $.fn.zTree.getZTreeObj("left-menu");
			//curMenu = zTree_Menu.getNodes()[0].children[0];
			//zTree_Menu.selectNode(curMenu);
			treeObj.addClass("showIcon");
			treeObj.hover(function () {
				///if (!treeObj.hasClass("showIcon")) {
				//	treeObj.addClass("showIcon");
				//}
			}, function() {
				//treeObj.removeClass("showIcon");
			});
			
			treeObj.find('> li').css({
				'border-bottom':'0px solid #343B43'
				});
			treeObj.find('.noline_docu').remove();
			treeObj.find('.ico_docu').css({
				height:24,
				width:24,
				'margin-top':11,
				'margin-left':8
			});
			
			//$("#left-menu_5_a").click();//自动点击节点
		});
		
		function actionbar_toggle(self){
			var $self = $(self);
			var $box_contain = $(".rbac-layout-center");
			var _height = $("#auto_panel").height();
			if($self.attr('status')=='open'){
				$('.rbac-layout-west').animate({
					'width':14
				});
				$('.rbac-layout-center').animate({
					'left':28,
					'_margin-left':28
				},function(){
					panel_refresh();
				});
				$('.operator-show').fadeOut();
				$self.attr('status','close');
				$self.css('background','url(static/admin/img/actionbar-toggle-open.png) center center no-repeat');
			}else{
				$('.operator-show').show();
				$('.rbac-layout-west').animate({
					'width':220
				});
				$('.rbac-layout-center').animate({
					'left':234,
					'_margin-left':234
				},function(){
					panel_refresh();
				});
				$self.attr('status','open');
				$self.css('background','url(static/admin/img/actionbar-toggle-close.png) center center no-repeat');
			}
		}
		
		function panel_refresh(){//刷新panel面板,获取最新数据（或者重置布局）
			if($("#auto_panel")[0]){//判断面板是否存在 
				$("#rbac-main-data").panel('destroy');
				var pp = $('<div id="rbac-main-data" style="position: relative;"></div>').appendTo($('.rbac-layout-center'));
				pp.panel({
					href:zTree_Menu.getSelectedNodes()[0].aj_url,
					border:false,
					height:'100%'
				});
			}
		}
	</script>
	<style type="text/css">
		/* 全屏自适应布局  */
		.rbac-layout-west,.rbac-layout-center{position:absolute;left:0;}
		.rbac-layout-west,.rbac-layout-center{top:76px;bottom:6px;_height:100%;overflow:auto;}
		.rbac-layout-west{width:202px;border:1px solid #585F62;}
		.rbac-layout-center{_position:relative;border:1px solid #585F62;left:208px;right:6px;_top:0;_left:0;_margin-left:208px;}
	</style>